package com.ruoyi.web.controller.biz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.biz.domain.BizSingleLineAnnotation;
import com.ruoyi.biz.service.IBizSingleLineAnnotationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 单条直线标注Controller
 * 
 * @author cc
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/system/single_line_annotation")
public class BizSingleLineAnnotationController extends BaseController
{
    @Autowired
    private IBizSingleLineAnnotationService bizSingleLineAnnotationService;

    /**
     * 查询单条直线标注列表
     */
    @PreAuthorize("@ss.hasPermi('system:single_line_annotation:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizSingleLineAnnotation bizSingleLineAnnotation)
    {
        startPage();
        List<BizSingleLineAnnotation> list = bizSingleLineAnnotationService.selectBizSingleLineAnnotationList(bizSingleLineAnnotation);
        return getDataTable(list);
    }

    /**
     * 导出单条直线标注列表
     */
    @PreAuthorize("@ss.hasPermi('system:single_line_annotation:export')")
    @Log(title = "单条直线标注", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizSingleLineAnnotation bizSingleLineAnnotation)
    {
        List<BizSingleLineAnnotation> list = bizSingleLineAnnotationService.selectBizSingleLineAnnotationList(bizSingleLineAnnotation);
        ExcelUtil<BizSingleLineAnnotation> util = new ExcelUtil<BizSingleLineAnnotation>(BizSingleLineAnnotation.class);
        util.exportExcel(response, list, "单条直线标注数据");
    }

    /**
     * 获取单条直线标注详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:single_line_annotation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizSingleLineAnnotationService.selectBizSingleLineAnnotationById(id));
    }

    /**
     * 新增单条直线标注
     */
    @PreAuthorize("@ss.hasPermi('system:single_line_annotation:add')")
    @Log(title = "单条直线标注", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizSingleLineAnnotation bizSingleLineAnnotation)
    {
        return toAjax(bizSingleLineAnnotationService.insertBizSingleLineAnnotation(bizSingleLineAnnotation));
    }

    /**
     * 修改单条直线标注
     */
    @PreAuthorize("@ss.hasPermi('system:single_line_annotation:edit')")
    @Log(title = "单条直线标注", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizSingleLineAnnotation bizSingleLineAnnotation)
    {
        return toAjax(bizSingleLineAnnotationService.updateBizSingleLineAnnotation(bizSingleLineAnnotation));
    }

    /**
     * 删除单条直线标注
     */
    @PreAuthorize("@ss.hasPermi('system:single_line_annotation:remove')")
    @Log(title = "单条直线标注", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizSingleLineAnnotationService.deleteBizSingleLineAnnotationByIds(ids));
    }


    /**
     * 获取图纸上所有线路信息
     */
    @PreAuthorize("@ss.hasPermi('system:single_line_annotation:query')")
    @GetMapping(value = "/getLinesByDrawingId/{drawingId}")
    public AjaxResult getLinesByDrawingId(@PathVariable("drawingId") Long drawingId)
    {
        return success(bizSingleLineAnnotationService.getLinesByDrawingId(drawingId));
    }
}
